package com.systop.dxjj.modules.recruitinfo.controller;

import com.systop.dxjj.common.utils.R;
import com.systop.dxjj.modules.recruitinfo.service.RecruitinfoService;
import com.systop.dxjj.modules.teacher.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

@RestController
@Api("招聘管理模块")

public class RecruitinfoController {

    @Autowired
    RecruitinfoService recruitinfoService;
    @Autowired
    TeacherService teacherService;

    //查询全部
    @GetMapping("/getAllrecruitinfo")
    @ApiOperation(value = "查询所有招聘信息",notes = "招聘信息")
    public R getAllrecruitinfo(){
        return recruitinfoService.getAll();
    }

    //根据id查询
    @GetMapping("/getRecruitinfoById/{teachid}")
    @ApiOperation(value = "根据id查询招聘信息",notes = "招聘信息")
    public R getRecruitinfoById(@PathVariable Integer teachid){
       return recruitinfoService.getById(teachid);
    }

    @GetMapping("/getRecruitinfoByName")
    @ApiOperation(value = "根据教师姓名查询招聘信息",notes = "招聘信息")
    public R getRecruitinfoByName(String teachname){
        return recruitinfoService.getByName(teachname);
    }

    //删除
    @GetMapping("/deleteById/{recruitid}")
    @ApiOperation(value = "根据id删除招聘信息",notes = "招聘信息")
    public R deleteRecruitinfoById(@PathVariable Integer recruitid){
     return recruitinfoService.deleteById(recruitid);
    }

    //添加
    @PostMapping("/addRecruitinfo")
    @ApiOperation(value = "添加招聘信息",notes = "招聘信息")
    public R addRecruitinfo(String turtortype, String pay, String location, String classtype, String detail, Integer teachid, HttpServletRequest request){

     return recruitinfoService.addRecruitinfo(turtortype,pay,location,classtype,detail,teachid,request);
    }

//    @RequestMapping("/user")
//    public String user(){
//        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
//        String name = authentication.getName();
//        System.out.println(name);
//        return name;
//    }
}
